﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Hisun.Controllers;
using Hisun.Models;

namespace Hisun
{
    /// <summary>
    /// 
    /// Copyright (C) 2008 HOHO``
    /// All rights reserved
    /// NameSpace:Hisun.Login
    /// Description :登陆页面,直接继承于PAGE类.唯一例外非验证页面.
    /// Created By QiuZhongJie At 2008/10/17 18:24
    /// </summary>
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //  litPeriod.Text = Application["accountPeriod"].ToString();
            // SetFocus(this.username);

            litPeriod0.Text = Application["accountPeriod"].ToString();
            SetFocus(this.username0);
        }

        /// <summary>
        /// Handles the Click event of the ImageBtnLogin control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.ImageClickEventArgs"/> instance containing the event data.</param>


        protected void Button1_Click(object sender, EventArgs e)
        {
            //if (string.IsNullOrEmpty(username.Text) || string.IsNullOrEmpty(password.Text))
            //    return;
            //try
            //{
            //    AbcLogin login = new AbcLogin(username.Text);
            //    if (login.CheckPassword(password.Text) != 0)
            //    {
            //        Response.Write("密码错误!");
            //        Response.End();
            //    }
            //    if (login.isAccountLock)
            //    {
            //        Response.Write("账户被停用");
            //        Response.End();
            //    }
            //    login.Enter();
            //    if (Request.QueryString["redir"] == null)
            //        Response.Redirect("~/Default.aspx");
            //    else
            //        Response.Redirect(Request.QueryString["redir"].ToString());
            //}
            //catch (Exception ex)
            //{
            //    Response.Write(ex.Message);
            //    Response.End();
            //}
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(username0.Text) || string.IsNullOrEmpty(password0.Text))
                return;
            try
            {
                AbcLogin login = new AbcLogin(username0.Text);
                if (login.CheckPassword(password0.Text) != 0)
                {
                    Response.Write("密码错误!");
                    Response.End();
                }
                if (login.isAccountLock)
                {
                    Response.Write("账户被停用");
                    Response.End();
                }
                login.Enter();
                if (Request.QueryString["redir"] == null)
                    Response.Redirect("~/Default.aspx");
                else
                    Response.Redirect(Request.QueryString["redir"].ToString());
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
                Response.End();
            }
        }
    }
}
